package hxy.dragon.ktor.router

import io.ktor.http.HttpStatusCode
import io.ktor.server.application.Application
import io.ktor.server.response.respond
import io.ktor.server.response.respondText
import io.ktor.server.routing.get
import io.ktor.server.routing.route
import io.ktor.server.routing.routing

/**
 * @description
 * @author HOX4SGH
 * @date 2024/7/14
 */

fun Application.configureIndexRouting() {
    routing {
//        全局异常的错误页面
//        https://ktor.io/docs/server-create-a-new-project.html#register-error-handlers

        route("/") {
            get {
                call.respondText("Hello World!")
            }
        }
        route("/api") {
            route("/order") {
                get {
                    call.respond(HttpStatusCode.OK, "success")
                }
                get("/{id}") {
                    call.respond(HttpStatusCode.OK, "success")
                }
            }
        }
    }
}
